﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NorthWindGridView
{
    public partial class FromNorthWind : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            NorthwindEntities entities = new NorthwindEntities();
            var employees = entities.Employees.Select(p => new {name=p.FirstName+" "+ p.LastName, ID=p.EmployeeID });
            if (!Page.IsPostBack) 
            {
                this.EmlpyeeGrid.DataSource = employees;
                this.DataBind();
            }

        }
        protected void GridViewCustomers_RowDataBound(object sender,
            GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                this.EmlpyeeGrid.SelectRow(e.Row.RowIndex);
                e.Row.Attributes["onmouseover"] =
                    "this.style.background='#EEEEEE';this.style.cursor='hand'";
                e.Row.Attributes["onmouseout"] =
                    "this.style.background='white'";
                e.Row.Attributes["onclick"] = "location.href='EmloyeeInformation.aspx?id="+this.EmlpyeeGrid.SelectedDataKey.Value+"'";
            }
        }
    }
}